class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int ret=0;
        for(int i=0,prevMin=INT_MAX;i<prices.size();i++)
        {
            ret=max(ret,prices[i]-prevMin);
            prevMin=min(prevMin,prices[i]);
        }
        return ret;
    }
};
